<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">
        <link rel="stylesheet" type="text/css" href="<c:url value="/static/jquery-easyui/themes/default/easyui.css"/>">
        <link rel="stylesheet" type="text/css"
            href="<c:url value="/static/jquery-easyui/themes/icon.css"/>">
        <script type="text/javascript"
            src="<c:url value="/static/jquery-easyui/jquery-1.6.min.js"/>"></script>
        <script type="text/javascript"
            src="<c:url value="/static/jquery-easyui/jquery.easyui.min.js"/>"></script>
        <script type="text/javascript"
            src="<c:url value="/static/jquery-easyui/plugins/jquery.panel.js"/>"></script>
        <script type="text/javascript"
            src="<c:url value="/static/jquery-easyui/plugins/jquery.datagrid.js"/>"></script>
        <script type="text/javascript"
            src="<c:url value="/static/jquery-easyui/plugins/jquery.messager.js"/>"></script>
        <script type="text/javascript"
            src="<c:url value="/static/jquery-easyui/ext-for-framework.js.jsp"/>"></script>
        <script type="text/javascript" src="<c:url value="/static/jquery-easyui/locale/easyui-lang-zh_CN.js"/>"></script>   
        <script type="text/javascript"
            src="<c:url value="/static/js/common.js"/>"></script>       
        
        <script type="text/javascript" src="<c:url value="/static/js/Loading.js"/>"></script>
        
        <script>
		
		    
			function excel(){
				$('#AddFoodForm').form('submit',
		 				{
		 					url:'<c:url value='/supplier/exportSupperExcelPrint.do'/>', //查询提交路径
		 					onSubmit:function()//提交按钮相应函数
		 					{
		 						var Allwidth = '100%';
		 		                var Allheight = '100%';
		 		                Loading.Show({width:Allwidth,height:Allheight});
		 		                setTimeout(function(){
		 		                    Loading.Hide();
		 		                },3000)
		 		                //校验
                                if($('#orderDate').datebox('getValue') ==''){
                                    $.messager.alert('提示','订单日期没有填写！','info');
                                    closeShow();
                                }
		 						return $('#AddFoodForm').form('validate');
		 					},
		 					success:function(data){
                                if(typeof(data)=='string'){
                            	    data =JSON.parse(data);
                                }
		                        if(data.success){
		                            $.messager.alert("提示", "生成成功！", 'info');
		                        }else{
		                            var message = "";
		                            if(data.msg == "locked"){
		                                message = "正在生成文件！";
		                            }else if(data.msg == "msg001"){
		                                message = "选择材料的时间已过，请联系采购部。";
		                            }else if(data.msg == "msg0001"){
		                            	message = "价格没有导入！请先导入报表价格！";
		                            }
		                            $.messager.alert("提示", message, 'warning');
		                        } 
		                    },
		                    error:function(){
		                        $.messager.alert("错误", "系统错误，请联系管理员！", 'error');
		                        return;
		                    }
		 				});
				
				
			}
			function exceldown(){
                $('#AddFoodForm').form('submit',
                        {
                            url:'<c:url value='/supplier/exportSupperExcelPrintDown.do'/>', //查询提交路径
                            onSubmit:function()//提交按钮相应函数
                            {
                                var Allwidth = '100%';
                                var Allheight = '100%';
                                Loading.Show({width:Allwidth,height:Allheight});
                                setTimeout(function(){
                                    Loading.Hide();
                                },3000)
                                //校验
                                if($('#orderDate').datebox('getValue') ==''){
                                    $.messager.alert('提示','订单日期没有填写！','info');
                                    closeShow();
                                }
                                return $('#AddFoodForm').form('validate');
                            },
                            success:function(data){
                            	if(typeof(data)=='string'){
                                    data =JSON.parse(data);
                                }
                                if(data.success){
                                    $.messager.alert("提示", "生成成功！", 'info');
                                }else{
                                    var message = "";
                                    if(data.msg == "locked"){
                                        message = "正在生成文件！";
                                    }else if(data.msg == "msg001"){
                                        message = "没有生成，请先生成。";
                                    }else if(data.msg == "msg0001"){
                                        message = "价格没有导入！请先导入报表价格！";
                                    }
                                    $.messager.alert("提示", message, 'warning');
                                } 
                            },
                            error:function(){
                                $.messager.alert("错误", "系统错误，请联系管理员！", 'error');
                                return;
                            }
                        });
                
                
            }
			function closeShow(){
				Loading.Hide();
			}
		</script>
			</head>
			<body>
			<table width="98%">
			<tr><td>
				<form id="AddFoodForm" name="AddFoodForm" method="post">
				<div style="height: auto; width:1180px;background: #fafafa; padding: 5px;" class="easyui-panel" title="送货报表导出打印" iconCls="icon-add" collapsible="true" minimizable="false" maximizable="false" closable="false">
			    <table cellpadding="5">
			      <tr>
                  	<td>日期</td>
                    <td>
 			            <input class="easyui-datebox" name="orderDate" id="orderDate" editable="false" data-options="required:true"/> 
 			        </td>
 			        <td>
 			        	<a href="#" class="easyui-linkbutton" onclick="excel();">生成</a>
 			        </td>
 			        <td>
                        <a href="#" class="easyui-linkbutton" onclick="exceldown();">下载</a>
                    </td>
                  </tr>
				        <input class="easyui-validatebox" type="hidden" name="idList"  />
				        <input class="easyui-validatebox" type="hidden" name="excelList"  />
				        <input class="easyui-validatebox" type="hidden" name="footList"  />
				        <input class="easyui-validatebox" type="hidden" name="supId" value="0"  />
                </table>
                </div>
                </form>
            </td></tr>
            </table>
			<table width="98%">
			<tr>
		</table>
	</body>
</html>